package com.eonmind.common.provider.entity.ai;

import com.eonmind.common.contract.enums.DelEnum;
import com.eonmind.common.contract.enums.ai.ConversationMessageTypeEnum;
import com.eonmind.common.contract.timer.Timer;
import com.mongoplus.annotation.ID;
import com.mongoplus.annotation.collection.CollectionName;
import com.mongoplus.annotation.index.MongoIndex;
import com.mongoplus.annotation.index.MongoTextIndex;
import com.mongoplus.enums.IdTypeEnum;
import lombok.Data;
import lombok.ToString;
import lombok.experimental.FieldNameConstants;

import java.util.List;

/**
 * 会话消息
 *
 * @author Xujie
 * @since 2025/5/5 10:54
 **/
@Data
@CollectionName("aiConversationMessage")
@MongoTextIndex(fields = {"messageContent"})
@FieldNameConstants
@ToString
public class AiConversationMessage {
    /**
     * 会话id
     */
    @ID(type = IdTypeEnum.AUTO)
    private Long id;


    /**
     * 会话ID
     */
    @MongoIndex
    private Long conversationId = 0L;

    /**
     * 用户id
     */
    @MongoIndex
    private Long userId;


    /**
     * 模型ID
     */
    @MongoIndex
    private Long modelId = 0L;

    /**
     * 模型ID
     */
    @MongoIndex
    private String modelName = "";

    /**
     * 信息类型
     * 0:用户 1:AI
     */
    @MongoIndex
    private Integer type = ConversationMessageTypeEnum.USER.getCode();

    /**
     * 消息媒体列表
     */
    private List<MessageMedia> messageMediaList;

    /**
     * 消息内容
     */
    @MongoIndex
    private String messageContent;

    /**
     * 创建时间
     */
    private Long createTime = Timer.currentTimestamp();

    /**
     * 更新时间
     */
    private Long updateTime = Timer.currentTimestamp();

    /**
     * 删除状态
     */
    @MongoIndex
    private Integer del = DelEnum.UN_DEL.getCode();

    @Data
    @ToString
    public static class MessageMedia {
        private String id;
        private String mimeType;
        private Object data;
        private String name;
    }

}
